Skip to content

fix(clerk-js): Remove session cookie when signing out and onBeforeSetActive - #3371

Merged
nikosdouvlis merged 7 commits into
mainfrom
vaggelis.fix/auth-state-not-updated-after-sign-out
May 16, 2024
Merged

fix(clerk-js): Remove session cookie when signing out and onBeforeSetActive#3371
nikosdouvlis merged 7 commits into
mainfrom
vaggelis.fix/auth-state-not-updated-after-sign-out

Conversation

@octoper

@octoper octoper commented May 13, 2024

Copy link
Copy Markdown
Contributor

Description

Problem:

Right now when signing out on Next.js with app router, there is a chance that you will get an error as we are clearing the app router cache before removing the session cookie.

Solution:

The solution is to move the removal of the session cookie before clearing the app router cache.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented May 13, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c469a32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@octoper

octoper commented May 13, 2024

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/chrome-extension 1.0.9-snapshot.v40b4e54
@clerk/clerk-js 5.2.5-snapshot.v40b4e54
@clerk/clerk-expo 1.1.1-snapshot.v40b4e54
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.v40b4e54

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.9-snapshot.v40b4e54 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.v40b4e54 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.v40b4e54 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.v40b4e54 --save-exact

@octoper

octoper commented May 13, 2024

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/chrome-extension 1.0.9-snapshot.v3595faf
@clerk/clerk-js 5.2.5-snapshot.v3595faf
@clerk/clerk-expo 1.1.1-snapshot.v3595faf
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.v3595faf

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.9-snapshot.v3595faf --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.v3595faf --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.v3595faf --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.v3595faf --save-exact

@octoper

octoper commented May 13, 2024

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/chrome-extension 1.0.9-snapshot.vb1a12ac
@clerk/clerk-js 5.2.5-snapshot.vb1a12ac
@clerk/clerk-expo 1.1.1-snapshot.vb1a12ac
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.vb1a12ac
@clerk/nextjs 5.0.9-snapshot.vb1a12ac

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.9-snapshot.vb1a12ac --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.vb1a12ac --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.vb1a12ac --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.vb1a12ac --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.9-snapshot.vb1a12ac --save-exact

@octoper

octoper commented May 14, 2024

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/chrome-extension 1.0.9-snapshot.v5ac0a48
@clerk/clerk-js 5.2.5-snapshot.v5ac0a48
@clerk/clerk-expo 1.1.1-snapshot.v5ac0a48
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.v5ac0a48
@clerk/nextjs 5.0.9-snapshot.v5ac0a48

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.9-snapshot.v5ac0a48 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.v5ac0a48 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.v5ac0a48 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.v5ac0a48 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.9-snapshot.v5ac0a48 --save-exact

@octoper
octoper force-pushed the vaggelis.fix/auth-state-not-updated-after-sign-out branch from 5ac0a48 to 3019c67 Compare May 15, 2024 10:18
@octoper

octoper commented May 15, 2024

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 1.1.5-snapshot.v58e76d6
@clerk/chrome-extension 1.0.10-snapshot.v58e76d6
@clerk/clerk-js 5.3.1-snapshot.v58e76d6
@clerk/elements 0.4.2-snapshot.v58e76d6
@clerk/clerk-expo 1.1.2-snapshot.v58e76d6
@clerk/express 0.0.8-snapshot.v58e76d6
@clerk/fastify 1.0.7-snapshot.v58e76d6
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/nextjs 5.0.10-snapshot.v58e76d6
@clerk/clerk-react 5.0.6-snapshot.v58e76d6
@clerk/remix 4.0.8-snapshot.v58e76d6
@clerk/clerk-sdk-node 5.0.7-snapshot.v58e76d6
@clerk/shared 2.1.1-snapshot.v58e76d6
@clerk/testing 1.0.5-snapshot.v58e76d6

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/backend

npm i @clerk/backend@1.1.5-snapshot.v58e76d6 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.10-snapshot.v58e76d6 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.3.1-snapshot.v58e76d6 --save-exact

@clerk/elements

npm i @clerk/elements@0.4.2-snapshot.v58e76d6 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.2-snapshot.v58e76d6 --save-exact

@clerk/express

npm i @clerk/express@0.0.8-snapshot.v58e76d6 --save-exact

@clerk/fastify

npm i @clerk/fastify@1.0.7-snapshot.v58e76d6 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.10-snapshot.v58e76d6 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.0.6-snapshot.v58e76d6 --save-exact

@clerk/remix

npm i @clerk/remix@4.0.8-snapshot.v58e76d6 --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.7-snapshot.v58e76d6 --save-exact

@clerk/shared

npm i @clerk/shared@2.1.1-snapshot.v58e76d6 --save-exact

@clerk/testing

npm i @clerk/testing@1.0.5-snapshot.v58e76d6 --save-exact

@octoper
octoper force-pushed the vaggelis.fix/auth-state-not-updated-after-sign-out branch from 5ac9520 to cf12ff3 Compare May 15, 2024 13:23
@octoper

octoper commented May 15, 2024

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/nextjs 5.0.11-snapshot.vcf12ff3

Tip: Use the snippet copy button below to quickly install the required packages.
gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.11-snapshot.vcf12ff3 --save-exact

@octoper octoper changed the title fix(nextjs): Auth state not updated correctly after sign out for App router fix(clerk-js): Remove session cookie when signing out and onBeforeSetActive May 15, 2024
@octoper
octoper marked this pull request as ready for review May 15, 2024 13:33

@nikosdouvlis nikosdouvlis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @octoper 👏🏻
I will test a little bit more, add a few unit tests and I'll merge right after

@brkalow brkalow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@nikosdouvlis
nikosdouvlis force-pushed the vaggelis.fix/auth-state-not-updated-after-sign-out branch from b4beda6 to c469a32 Compare May 16, 2024 01:17
@nikosdouvlis
nikosdouvlis merged commit 1fdd436 into main May 16, 2024
@nikosdouvlis
nikosdouvlis deleted the vaggelis.fix/auth-state-not-updated-after-sign-out branch May 16, 2024 02:04
@clerk-cookie clerk-cookie mentioned this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants